import {
	Entity,
	Column,
	PrimaryGeneratedColumn,
	CreateDateColumn,
	UpdateDateColumn,
} from "typeorm";
import { DateTransformer } from "../../../common/transformers/date.transformer";

@Entity("uploads")
export class Upload {
	@PrimaryGeneratedColumn()
	id: number;

	@Column({ length: 255 })
	originalName: string;

	@Column({ length: 255 })
	filename: string;

	@Column({ length: 100 })
	mimetype: string;

	@Column()
	size: number;

	@Column({ length: 255 })
	path: string;

	@Column({ length: 255 })
	url: string;

	@Column({ length: 50, default: "image" })
	type: string;

	@CreateDateColumn({
		name: "created_at",
		type: "datetime",
		transformer: new DateTransformer(),
		nullable: false,
	})
	createdAt: Date;

	@UpdateDateColumn({
		name: "updated_at",
		type: "datetime",
		transformer: new DateTransformer(),
		nullable: false,
	})
	updatedAt: Date;
}
